﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using DTO;
namespace NhaTroService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface INhaTroService
    {
        [OperationContract]
        [WebInvoke(Method="POST",
            UriTemplate = "test",
            ResponseFormat = WebMessageFormat.Json,
            RequestFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare
        )]
        string test(string json);

        [WebGet(UriTemplate="test/{json}",
            ResponseFormat = WebMessageFormat.Json,
            RequestFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare
        )]
        string abc(string json);

        [OperationContract]
        [WebGet(UriTemplate="GetData/{value}",ResponseFormat=WebMessageFormat.Json,BodyStyle = WebMessageBodyStyle.Bare)]
        string GetData(string value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // ===================== DULIEUNHATRO
        // ===> View
        [OperationContract]
        //WebOperationContext
        [WebGet(UriTemplate = "NhaTro/DanhSach", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        DuLieuDTO[] GetLisAlltNhaTro();
        [OperationContract]
        [WebGet(UriTemplate = "NhaTro/Quan/{TenQuan}", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
        DuLieuDTO[] GetNhaTroByQuan(string TenQuan);
        [OperationContract]
        [WebGet(UriTemplate = "NhaTro/Phuong/{TenPhuong}", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
        DuLieuDTO[] GetNhaTroByPhuong(string TenPhuong);
        [OperationContract]
        [WebGet(UriTemplate = "NhaTro/Duong/{TenDuong}", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
        DuLieuDTO[] GetNhaTroByDuong(string TenDuong);

        [OperationContract]
        [WebGet(UriTemplate = "NhaTro/{searchText}", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        DuLieuDTO[] GetNhaTroBySearchText(string searchText);


        [OperationContract]
        [WebGet(UriTemplate = "TenDiaDiem/{TenDD}", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        string GetLastID(string TenDD);
        [OperationContract]
        [WebGet(UriTemplate = "Phuong/DanhSach", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        PhuongDTO[] GetListPhuong();
        [OperationContract]
        [WebGet(UriTemplate = "Duong/DanhSach", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        DuongDTO[] GetListDuong();

        [OperationContract]
        [WebGet(UriTemplate = "Duong/AutoComplete/{keyword}", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        string SearchDuong(string keyword);
        [OperationContract]
        [WebGet(UriTemplate = "NhaTro/DanhSach/{MaNhaTro}", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        DuLieuDTO[] GetNhaTroById(string MaNhaTro);

        
        
        
        // ===> Action - Add - Update - Delete
        /*
         * Thực ra các mã là long chứ k0 phải int(do lúc trức đồ àn làm long) - 
         * -->chuyển thành string cho k0 lỗi khi chạy service, khi xử lý parse lại thành long
         */
        [OperationContract]
        [WebInvoke(UriTemplate = "Add", Method = "*",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        bool InsertNhaTro(string strJSONDULIEU);


        [OperationContract]
        [WebGet(UriTemplate = "NhaTro/Them/?value={value}", 
            ResponseFormat = WebMessageFormat.Json, 
            BodyStyle = WebMessageBodyStyle.Bare)]
        bool ThemNhaTro(string value);

        [OperationContract]
        [WebInvoke(UriTemplate = "NhaTro/Xoa/{MaNhaTro}", 
            Method = "DELETE", RequestFormat = WebMessageFormat.Json, 
            ResponseFormat=WebMessageFormat.Json,
            BodyStyle=WebMessageBodyStyle.Bare)]
        bool DeleteNhaTro(string MaNhaTro);

        //[OperationContract]
        //[WebGet(UriTemplate = "NhaTro/xoa/{MaNhaTro}")]
        //bool DeleteNhaTro(string MaNhaTro);

        [OperationContract]
        [WebInvoke(UriTemplate = "Update", Method = "PUT", 
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        bool UpdateNhaTro(string strJSONDULIEU);


        [OperationContract]
        [WebGet(UriTemplate = "NhaTro/CapNhat/?value={value}",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        bool CapNhatNhaTro(string value);
        // ===================== DUONG
    }


    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }
}
